package com.wangtao.firstapp.adapters;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import java.util.ArrayList;

/**
 * 消息界面Fragment适配器
 * Created by lanouhn on 16/8/27.
 */
public class MessageAdapter extends FragmentStatePagerAdapter {
    private ArrayList<String> tabnames;
    private ArrayList<Fragment> fragments;

    public MessageAdapter(FragmentManager fm, ArrayList<String> tabnames, ArrayList<Fragment> fragments) {
        super(fm);
        this.tabnames = tabnames;
        this.fragments = fragments;
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return tabnames.get(position);
    }
}
